<!DOCTYPE html>
<html lang="zh-CN">

<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
</head>

<body>
   <canvas id="c1" width="800" height="800"></canvas>

   <script>
      const c1 = document.getElementById('c1')
      const ctx = c1.getContext('2d')
      // 三角形绘制
      ctx.beginPath()
      ctx.moveTo(400, 400)
      ctx.lineTo(200, 200)
      ctx.lineTo(600, 200)
      ctx.lineTo(400, 400)
      ctx.stroke()
      ctx.closePath()
   </script>
</body>

</html>